package com.fafu.ioc.controller;

import com.fafu.ioc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {
//    //属性注入, 无法注入final属性
//    @Autowired
//    private UserService userService;
    private UserService userService;

    //存在多个默认使用无参的构造函数
    /*
    public UserController(){

    }
     */
//    public UserController(){
//
//    }
//    //构造方法注入
//    @Autowired//默认走这个
//    public UserController(UserService userService){
//        this.userService = userService;
//    }

    //set方法注入
    @Autowired
    public void setUserService(UserService userService){
        this.userService = userService;
    }
    public void say(){
        System.out.println("UserController say.....");
        userService.say();
    }
}
